<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="jakarta.tags.core" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>病人详情 - 医疗预约系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background-color: #f5f5f5;
            min-height: 100vh;
        }
        
        .header {
            background-color: #4a90e2;
            color: white;
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .header h1 {
            font-size: 24px;
        }
        
        .header .user-info {
            display: flex;
            align-items: center;
        }
        
        .header .user-info span {
            margin-right: 15px;
        }
        
        .header .logout-btn {
            color: white;
            text-decoration: none;
            padding: 5px 10px;
            background-color: rgba(255,255,255,0.2);
            border-radius: 4px;
            transition: background-color 0.3s;
        }
        
        .header .logout-btn:hover {
            background-color: rgba(255,255,255,0.3);
        }
        
        .container {
            display: flex;
            min-height: calc(100vh - 60px);
        }
        
        .sidebar {
            width: 200px;
            background-color: #333;
            color: white;
        }
        
        .sidebar ul {
            list-style: none;
        }
        
        .sidebar li {
            padding: 15px 20px;
        }
        
        .sidebar a {
            color: white;
            text-decoration: none;
            display: block;
            transition: background-color 0.3s;
        }
        
        .sidebar li:hover {
            background-color: #4a90e2;
        }
        
        .sidebar li.active {
            background-color: #4a90e2;
        }
        
        .content {
            flex: 1;
            padding: 20px;
        }
        
        .page-title {
            font-size: 20px;
            margin-bottom: 20px;
            color: #333;
            display: flex;
            align-items: center;
        }
        
        .page-title .back-link {
            margin-left: auto;
            color: #4a90e2;
            text-decoration: none;
        }
        
        .page-title .back-link:hover {
            text-decoration: underline;
        }
        
        .patient-info-card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
            margin-bottom: 30px;
        }
        
        .info-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }
        
        .info-item {
            display: flex;
            margin-bottom: 15px;
        }
        
        .info-label {
            width: 100px;
            color: #666;
            font-weight: normal;
        }
        
        .info-value {
            color: #333;
            flex: 1;
        }
        
        .medical-record-card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }
        
        .card-title {
            font-size: 18px;
            margin-bottom: 15px;
            color: #333;
            border-bottom: 1px solid #eee;
            padding-bottom: 10px;
        }
        
        .record-content {
            white-space: pre-wrap;
            line-height: 1.6;
            color: #333;
        }
        
        .no-record {
            color: #999;
            font-style: italic;
            text-align: center;
            padding: 20px;
        }
        
        .action-buttons {
            margin-top: 20px;
            text-align: center;
        }
        
        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            text-decoration: none;
            font-size: 16px;
            transition: background-color 0.3s;
        }
        
        .btn-primary {
            background-color: #4a90e2;
            color: white;
        }
        
        .btn-primary:hover {
            background-color: #357abD;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>病人详情</h1>
        <div class="user-info">
            <span>欢迎您，${loginDoctor.doctorName}</span>
            <a href="/doctorLogout" class="logout-btn">退出登录</a>
        </div>
    </div>
    
    <div class="container">
        <div class="sidebar">
            <ul>
                <li><a href="/doctor/workspace">工作台</a></li>
                <li><a href="/doctor/appointments">我的排班</a></li>
                <li class="active"><a href="/doctor/patients">病人管理</a></li>
            </ul>
        </div>
        
        <div class="content">
            <h2 class="page-title">
                病人信息详情
                <a href="/doctor/patients" class="back-link">返回列表</a>
            </h2>
            
            <!-- 病人基本信息卡片 -->
            <div class="patient-info-card">
                <h3 class="card-title">基本信息</h3>
                <div class="info-row">
                    <div>
                        <div class="info-item">
                            <span class="info-label">姓名：</span>
                            <span class="info-value">${visit.userName}</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">性别：</span>
                            <span class="info-value">${visit.gender}</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">年龄：</span>
                            <span class="info-value">${visit.age}</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">联系电话：</span>
                            <span class="info-value">${visit.phone}</span>
                        </div>
                    </div>
                    <div>
                        <div class="info-item">
                            <span class="info-label">预约科室：</span>
                            <span class="info-value">${visit.departmentName}</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">预约医生：</span>
                            <span class="info-value">${visit.doctorName}</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">预约时间：</span>
                            <span class="info-value">${visit.appointmentTime}</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">就诊状态：</span>
                            <span class="info-value">${visit.status == 1 ? '待诊断' : '已诊断'}</span>
                        </div>
                    </div>
                </div>
                
                <div class="info-item">
                    <span class="info-label" style="width: 80px;">症状描述：</span>
                    <span class="info-value">${visit.symptom}</span>
                </div>
            </div>
            
            <!-- 病历记录卡片 -->
            <div class="medical-record-card">
                <h3 class="card-title">病历记录</h3>
                
                <c:choose>
                    <c:when test="${not empty visit.diagnosis}">
                        <div class="info-item">
                            <span class="info-label" style="width: 80px;">诊断结果：</span>
                            <span class="info-value record-content">${visit.diagnosis}</span>
                        </div>
                        
                        <div class="info-item">
                            <span class="info-label" style="width: 80px;">治疗方案：</span>
                            <span class="info-value record-content">${visit.treatment}</span>
                        </div>
                        
                        <div class="info-item">
                            <span class="info-label" style="width: 80px;">医嘱：</span>
                            <span class="info-value record-content">${visit.advice}</span>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <div class="no-record">暂无病历记录</div>
                    </c:otherwise>
                </c:choose>
                
                <c:if test="${visit.status == 1}">
                    <div class="action-buttons">
                        <a href="/doctor/medicalRecord/write?visitId=${visit.visitId}" class="btn btn-primary">写病历</a>
                    </div>
                </c:if>
            </div>
        </div>
    </div>
</body>
</html>